package com.utils.picTxt.pic
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class PicItem extends Sprite
	{
		private var _cls:Class;
		private var _shape:Shape;
		public function PicItem(cls:Class)
		{
			_cls = cls;
			_shape = new Shape();
			init();
		}
		
		private function init():void
		{
			_shape.graphics.beginFill(0xFFFFFF,.7);
			_shape.graphics.drawRect(0,0,24,24);
			_shape.graphics.endFill();
			this.addChild(_shape);
			_shape.visible = false;
			this.addChild(new _cls());
			this.addEventListener(MouseEvent.MOUSE_OVER,onMouseHandler);
			this.addEventListener(MouseEvent.MOUSE_OUT,onMouseHandler);
			this.addEventListener(Event.REMOVED_FROM_STAGE,onClearHandler);
		}
		
		private function onClearHandler(e:Event):void
		{
			this.removeEventListener(MouseEvent.MOUSE_OVER,onMouseHandler);
			this.removeEventListener(MouseEvent.MOUSE_OUT,onMouseHandler);
			this.removeEventListener(Event.REMOVED_FROM_STAGE,onClearHandler);
			while(this.numChildren) removeChildAt(0);
		}
		
		private function onMouseHandler(e:MouseEvent):void
		{
			if(e.type == MouseEvent.MOUSE_OVER){
				_shape.visible = true;
			}else{
				_shape.visible = false;
			}
		}		
		
		
		
		
		
		
	}
}